#include <iostream>
#include <ctime>
#include "membersmenu.h"
#include "menu.h"

using namespace std;

string LibMember::DeadLine()
{
	time_t now = time(0);
	tm *ltm = localtime(&now);
	Menu m;
	
	int yearI;
	int monthI;
	int dayI = ltm->tm_mday;
	
	if(ltm->tm_mon < 11)
	{
		monthI = 2 + ltm->tm_mon;
		yearI = 1900 + ltm->tm_year;
		
	}
	else
	{
		yearI = 1901 + ltm->tm_year;
		monthI = ltm->tm_mon - 10;
	}
	
 	string year = m.Menu::InttoString(yearI);
	string month = m.Menu::InttoString(monthI);
	string day = m.Menu::InttoString(dayI);
	
	if (month.size() == 1)
		month = "0" + month;
		
	if (day.size() == 1)
		day = "0" + day;
	
	string  str = year + "." + month + "." + day;
	return str;
}

std::ostream &operator<<(std::ostream &out, LibMember &m)
{	
	out << m.Name() << "|" << m.Status() << "|" << m.Memberid() << "|" << m.Address() << "|" << m.Email() << "|" << m.Debit();
	return out;
}